//
//  LoginModel.m
//  YuYingEDU
//
//  Created by 胡波 on 2018/1/9.
//  Copyright © 2018年 胡波. All rights reserved.
//

#import "LoginModel.h"
#import "YYModel.h"

@implementation LoginModel

//- (void)encodeWithCoder:(NSCoder *)aCoder {
//    [self yy_modelEncodeWithCoder:aCoder];
//}
//- (id)initWithCoder:(NSCoder *)aDecoder {
//    self = [super init];
//    return [self yy_modelInitWithCoder:aDecoder];
//}

+ (NSDictionary *)modelCustomPropertyMapper
{
    return @{@"uid" : @"id"};
}

static LoginModel *_instance;

+ (instancetype)shareLogin {
    
    return [[self alloc]init];
    
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (_instance == nil) {
            _instance = [super allocWithZone:zone];
        }
    });
    return _instance;
}

- (NSString *)token {
    
    if (!_token) {
        NSString *t = GETDATAFROMUSERDEFAULT(@"token");
        _token = t?t:@"";
    }
    return _token;
    
}

- (NSString *)role {
    
    if (!_role) {
        NSString *r = GETDATAFROMUSERDEFAULT(@"role");
        _role = r?r:@"";
    }
    return _role;
    
}

- (NSString *)uid {
    
    if (!_uid) {
        NSString *u = GETDATAFROMUSERDEFAULT(@"uid");
        _uid = u?u:@"";
    }
    return _uid;
    
}

- (NSString *)username {
    
    if (!_username) {
        NSString *u = GETDATAFROMUSERDEFAULT(@"username");
        _username = u?u:@"";
    }
    return _username;
    
}

- (NSString *)name {
    
    if (!_name) {
        NSString *u = GETDATAFROMUSERDEFAULT(@"name");
        _name = u?u:@"";
    }
    return _name;
    
}

- (NSDictionary *)params {
    
    if (!_params) {
        _params = @{
                    @"uid":self.uid,
                    @"username":self.username,
                    @"token":self.token
                    };
    }
    return _params;
    
}

- (NSInteger)isLogin {
    
    if (!_isLogin) {
        _isLogin = 0;
    }
    return _isLogin;
    
}

@end
